<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('报纸列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>报纸种类：</label>
                                <select id="name" name="name" th:with="type=${@dict.getType('baozhi_baozhi')}">
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>所属部门：</label>
<!--                                <input type="text" name="deptId"/>-->
                                <select name="deptId" th:with="type=${@dict.getDept()}"class="form-control m-b" >
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>数量：</label>
                                <input type="text" name="shuLiang"/>
                            </li>
                            <li>
                                <label>年度：</label>
                                <input id="year" type="text" name="year"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
<!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="baozhi:baozhi:add">-->
<!--                    <i class="fa fa-plus"></i> 添加-->
<!--                </a>-->
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="baozhi:baozhi:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="baozhi:baozhi:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="baozhi:baozhi:export">-->
<!--                    <i class="fa fa-download"></i> 导出-->
<!--                </a>-->
                <a class="btn btn-success" onclick="fenfabaozhi()">
                    <i class="fa fa-remove"></i> 分发
                </a>
                <a class="btn btn-success" onclick="$.operate.jieshu()">
                    <i class="fa fa-remove"></i> 结束
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('baozhi:baozhi:edit')}]];
        var removeFlag = [[${@permission.hasPermi('baozhi:baozhi:remove')}]];
        var nameDatas = [[${@dict.getType('baozhi_baozhi')}]];
        var prefix = ctx + "baozhi/baozhi";

        function fenfabaozhi(){
            var name=document.getElementById('name').value;
            var year=document.getElementById('year').value;
            if (name==""||year==""){
                alert("请输入报纸种类和年度")

            }else {

            $.post(prefix+"/fenfabaozhi", {name:name,year:year}, function (result) {
                if(result == 1){
                    $.modal.alertSuccess("操作成功")
                }else{
                    $.modal.alertError(result.msg);
                }
                // if (typeof callback == "function") {
                //     callback(result);
                // }
                // if (result.code == web_status.SUCCESS) {
                //     $.modal.alertSuccess(result.msg)
                // } else if (result.code == web_status.WARNING) {
                //     $.modal.alertWarning(result.msg)
                // } else {
                //     $.modal.alertError(result.msg);
                // }
                $.modal.closeLoading();

        $.ajax(config)


            }, "json");
            }

        }
        $(function() {
            morenniandu()
            var options = {
                url: prefix + "/list1",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "报纸",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'name',
                    title: '报纸种类',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(nameDatas, value);
                    }
                },
                {
                    field: 'deptId',
                    title: '所属部门'
                },
                {
                    field: 'shuLiang',
                    title: '数量'
                },
                {
                    field: 'year',
                    title: '年度'
                },
                {
                    title: '操作',
                    align: 'center',
                    visible: false,
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function morenniandu() {
            var date = new Date();
            var y = date.getFullYear();<!--年-->
            // alert(y)
            $('#year').val(y);
        }
    </script>
</body>
</html>